page_ckjl = (state={},action)->
  switch action.type
    when 'CKJL/GET_LIST_START'
      Object.assign {},state,{isLoading:true,refreshing:false}
    when 'CKJL/GET_LIST_COMPLETED'
        Object.assign {},state,{
          list:state.list.concat(action.payload.list)
          isLoading:false
          pageIndex:if action.payload.list.length > 0 then state.pageIndex+1 else state.pageIndex
          completed:action.payload.list.length < 20
          lastFetchTime:action.payload.lastFetchTime
        }

    when 'CKJL/REFRESH_LIST_START'
      Object.assign {},state,{
        list:[]
        isLoading:false
        refreshing:true
      }
    when 'CKJL/REFRESH_LIST_COMPLETED'
      Object.assign {},state,{
        list:action.payload.list
        isLoading:false
        pageIndex:1
        refreshing:false
        completed:action.payload.list.length<20
      }
    else
      state

module.exports = page_ckjl
